<?php
class Nhapxe_preview extends Controller {
	private $data;
	
	function index() {		
		$this -> loadTools();
		$this -> loadData();
		$this -> load -> view('nhapxe/view_preview',$this -> data );
	}
	
	function loadTools() {
		$this -> load -> helper('form');
		$this -> load -> helper('url');		
		$this -> load -> helper('My_utilities');
		$this -> load -> model('Xemay');
	}
	
	function loadData() {
		$this -> data = array();
		
		$this -> data['title'] = 'Tong ket';
		$this -> data['choosenItem'] = $_POST['choosenItem'];
		$this -> data['gia_nhap'] = $_POST['gia_nhap'];
		$this -> data['tong_cong'] = $_POST['tong_cong'];
		$this -> data['so_luong'] = $_POST['so_luong'];
		
		
		//TODO: get it from session
		$this -> data['nguoi_nhap'] = 'lan';		
		
		$this -> data['sk'] = array();
		$this -> data['sm'] = array();
		
		for($i = 0; $i < $_POST['so_luong'] ; $i++) {
			$skstr = "SK$i";
			$smstr = "SM$i";			
			array_push($this -> data['sk'],$_POST[$skstr]);
			array_push($this -> data['sm'],$_POST[$smstr]);
		}
		
	}
}